import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 74646
 * Date: 2022-02-28
 * Time: 15:09
 */
class MyQueue {
    Stack<Integer> stck1;
    Stack<Integer> stck2;
    public MyQueue() {
        stck1 = new Stack<>();
        stck2 = new Stack<>();
    }

    public void push(int x) {
        stck1.push(x);
    }

    public int pop() {
        if(stck2.empty()){
            int size = stck1.size();
            int val = -1;
            for(int i=0;i<size;i++){
                val = stck1.pop();
                stck2.push(val);
            }
        }
        return stck2.pop();
    }

    public int peek() {
        if(stck2.empty()){
            int size = stck1.size();
            int val = -1;
            for(int i=0;i<size;i++){
                val = stck1.pop();
                stck2.push(val);
            }
        }
        return stck2.peek();
    }

    public boolean empty() {
        return stck2.empty() && stck1.empty();
    }
}

